<!DOCTYPE html>
<html lang="en">
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>编辑修改页</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="/static/H/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/H/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/static/H/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="/static/H/css/animate.css" rel="stylesheet">
    <link href="/static/H/css/style.css?v=4.1.0" rel="stylesheet">
</head>

<body class="gray-bg">

<!--添加任务的弹出窗口-->
<div >
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <div class="row">
                    <form role="form" id="form" method="post" action="{:url('Events/modify')}">
                        <div class="form-group">
                            <label>任务标题：</label>
                            <input type="text" name="title" value="{$data['title']}" placeholder="请输入任务标题" class="form-control">
                        </div>
                        <div class="form-group">
                            <label>任务详情：</label>
                            <textarea rows="5" name="content"  placeholder="请输入对任务的详细描述" class="form-control">{$data['content']}</textarea>
                        </div>
                        <div class="form-group">
                            <label>截止日期：</label>
                            <input id="deadline" name="deadline" value="{$data['deadline']}" class="laydate-icon form-control">
                        </div>

                        <div>
                            <input type="hidden" name="id" value="{$data.id}">
                            <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit"><strong>确认修改</strong></button>
                            <button class="btn btn-sm btn-primary pull-left m-t-n-xs" onclick="history.back(-1)"><strong>返回上一级</strong></button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/static/H/js/jquery.min.js?v=2.1.4"></script>
<script src="/static/H/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/static/H/js/jQuery.form.js"></script>
<script src="/static/H/js/plugins/layer/laydate/laydate.js"></script>
<script src="/static/H/js/plugins/layer/3.1/layer.js"></script>
<script src="/static/H/js/plugins/validate/1.14/jquery.validate.js"></script>

<!-- 自定义js -->

<script>
    //日期控件
    laydate({
        elem:'#deadline',
        event:'focus',
        format:'YYYY-MM-DD hh:mm:ss',
        istime: true,
    });

    //验证表单数据
    $('#form').validate({
        //定义表单验证规则
        rules:{
            title:{
                required:true,
                minlength:2,
                maxlength:100,
            },
            deadline:{
                required: true,
                date:true,
            }
        },
        //表单验证失败的提示信息
        messages:{
            title:{
                required:"请输入任务标题",
                minlength: "任务标题的长度不能小于2个字符",
                maxlength:"任务标题长度不能大于100个字符"
            },
            deadline:{
                required: "请选择正确日期",
                date: "请选择截止日期"
            }

        },
        //修改提交操作,默认提交是submit被点击
        //使用ajax提交
        submitHandler:function (form) {
            $(form).ajaxSubmit(function (e) {
                //ajax提交后的返回值
                if (!e.code){
                    layer.alert(e.info)
                } else{
                    window.location.href= '{:url("detal")}';
                }

            })
        }
    });

</script>




</body>
</html>